﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace The_LarX
{
    public class LarCommandWindow : GuideLikeComponent
    {
        private MenuScreen Screen;

        private float InitialX;
        private float InitialY;
        private float SquareWidth;
        private float SquareHeight;

        public LarCommandWindow()
        {
            Screen = new MenuScreen(false);
            Engine.GameScreens.Remove(Screen);

            PresentationParameters pp = Engine.GraphicsDevice.PresentationParameters;
            InitialX = (pp.BackBufferWidth / 3) + 30;
            InitialY = pp.BackBufferHeight / 6;
            SquareWidth = pp.BackBufferWidth / 4;
            SquareHeight = (pp.BackBufferHeight / 6) + (pp.BackBufferHeight / 2);

            Sprite2D fps_sprite = new Sprite2D(new Vector2(InitialX, InitialY + 30), "FPS Show");
            MenuEntry fps_entry = new MenuEntry(fps_sprite, FPS_Click, Screen);

            Sprite2D debug = new Sprite2D(new Vector2(InitialX, InitialY + (30 * 2)), "Debug Mode");
            MenuEntry DebugEntry = new MenuEntry(debug, DebugClick, Screen);

            Sprite2D console = new Sprite2D(new Vector2(InitialX, InitialY + (30 * 3)), "Console");
            MenuEntry ConsoleEntry = new MenuEntry(console, ConsoleClick, Screen);

            Screen.ReorderEntrys(pp.BackBufferHeight);
            Screen.SelectedEntry = 0;

            Screen.Loaded = true;
        }
        private void FPS_Click()
        {
            Engine.Counter.Visible = !Engine.Counter.Visible;
            if (Engine.Counter.Visible)
            {
                if (Engine.Counter.FPSType == FPSType.Number)
                    Engine.Counter.FPSType = FPSType.Graphic;
                else
                    Engine.Counter.FPSType = FPSType.Number;
            }
        }
        private void DebugClick()
        {
            Engine.DebugMode = !Engine.DebugMode;
        }
        private void ConsoleClick()
        {
            Engine.Console.Visible = !Engine.Console.Visible;
        }

        public override void Update()
        {
            Screen.Update();
        }

        public override void Draw()
        {
            Color color = Color.Gray;
            color.A = 240;
            Engine.RenderManager.DrawRectangle(color, new Rectangle((int)InitialX, (int)InitialY, (int)SquareWidth, (int)SquareHeight), null);

            Screen.Draw();
        }
    }
}
